package com.example.compont;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.compont.gridview.GridViewActivity;
import com.example.compont.listview.ListViewActivity;


public class MainActivity extends AppCompatActivity {
    private String TAG = "MainActivity";
    private Button mButton1, mButton2, mButton3, mButton4, mButton5, mButton6, mButton7, mButton8;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mButton1 = findViewById(R.id.btn_bt1);
        mButton2 = findViewById(R.id.btn_bt2);
        mButton3 = findViewById(R.id.btn_bt3);
        mButton4 = findViewById(R.id.btn_bt4);
        mButton5 = findViewById(R.id.btn_bt5);
        mButton6 = findViewById(R.id.btn_bt6);
        mButton7 = findViewById(R.id.btn_bt7);
        mButton8 = findViewById(R.id.btn_bt8);
        setListeners();
    }

    private void setListeners() {
        OnClick onClick = new OnClick();
        mButton1.setOnClickListener(onClick);
        mButton2.setOnClickListener(onClick);
        mButton3.setOnClickListener(onClick);
        mButton4.setOnClickListener(onClick);
        mButton5.setOnClickListener(onClick);
        mButton6.setOnClickListener(onClick);
        mButton7.setOnClickListener(onClick);
        mButton8.setOnClickListener(onClick);
    }
    
    public class OnClick implements View.OnClickListener{

        @Override
        public void onClick(View v) {
            Intent intent = null;
            switch (v.getId()) {
                case R.id.btn_bt1:
                    intent = new Intent(MainActivity.this, TextViewActivity.class);
                    break;
                case R.id.btn_bt2:
                    intent = new Intent(MainActivity.this, ButtonActivity.class);
                    break;
                case R.id.btn_bt3:
                    intent = new Intent(MainActivity.this, EditTextActivity.class);
                    break;
                case R.id.btn_bt4:
                    intent = new Intent(MainActivity.this, RadioButtonActivity.class);
                    break;
                case R.id.btn_bt5:
                    intent = new Intent(MainActivity.this, CheckBoxActivity.class);
                    break;
                case R.id.btn_bt6:
                    intent = new Intent(MainActivity.this, ImageViewActivity.class);
                    break;
                case R.id.btn_bt7:
                    intent = new Intent(MainActivity.this, ListViewActivity.class);
                    break;
                case R.id.btn_bt8:
                    intent = new Intent(MainActivity.this, GridViewActivity.class);
                    break;
            }
            startActivity(intent);
        }
    }
}